﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="备件到货记录录入.aspx.cs" Inherits="syc.Store.备件到货记录录入" %>
<html>
<head>
<title></title>
<style>
div.AutoComplete_Container{position:absolute; z-index:2;border:solid 1px #dd3333;background-color:#ffffff;padding:1px;font-size:14px;color:#ff0000;}
#AutoComplete_CurrentLine{ background-color:#0000cc;}
tr.AutoComplete_Row{font-size:14px;color:#6f320a;height:18px;cursor:pointer;}
tr.AutoComplete_HotRow{font-size:14px;color:#6f320a; background-color:#ffee88;height:18px;cursor:pointer;}
tr{height:34px;}
</style>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="select @类别ID=t1.类别ID,@计划年度=t1.计划年度,@计划月份=t1.计划月份
,@日期=t1.日期,@数量=t1.数量,@单价=t1.单价,@厂商=isnull(t1.厂商,''),@经办人=isnull(t1.经办人,'')
,@保管员=isnull(t1.保管员,''),@备注=isnull(t1.备注,''),@品名=t2.品名
,@规格=isnull(t2.规格,''),@单位=isnull(t2.单位,'')
FROM 备件到货 t1 left outer join 备品备件 t2 on t2.ID=t1.类别ID where t1.ID=@ID"

InsertCommand="insert into 备件到货(类别ID,计划年度,计划月份,日期,数量,单价,厂商,经办人,保管员,备注)
values(@类别ID,@计划年度,@计划月份,@日期,@数量,@单价,@厂商,@经办人,@保管员,@备注);
select @ID=@@IDENTITY;"
UpdateCommand="update 备件到货 set 类别ID=@类别ID,计划年度=@计划年度,计划月份=@计划月份,日期=@日期
,数量=@数量,单价=@单价,厂商=@厂商,经办人=@经办人,保管员=@保管员,备注=@备注 where ID=@ID"
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    onselected="SqlDataSource1_Selected" oninserted="SqlDataSource1_Inserted">
<SelectParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" DefaultValue="0" />
<asp:Parameter Name="类别ID" DbType="Int32" Size="4" Direction="Output"  />
<asp:Parameter Name="计划年度" DbType="Int16" Size="2" Direction="Output" />
<asp:Parameter Name="计划月份" DbType="Byte" Size="1" Direction="Output" />
<asp:Parameter Name="日期" DbType="Date"  Size="3" Direction="Output" />
<asp:Parameter Name="数量" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="单价" DbType="Double" Size="9" Direction="Output" />
<asp:Parameter Name="厂商" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="经办人" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="保管员" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="备注" DbType="String"  Size="100" Direction="Output" />
<asp:Parameter Name="品名" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="规格" DbType="AnsiString"  Size="40" Direction="Output" />
<asp:Parameter Name="单位" DbType="AnsiString"  Size="10" Direction="Output" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="类别ID" DbType="Int32" Size="4"  />
<asp:Parameter Name="计划年度" DbType="Int16" Size="2" />
<asp:Parameter Name="计划月份" DbType="Byte" Size="1" />
<asp:Parameter Name="日期" DbType="Date"  Size="3" />
<asp:Parameter Name="数量" DbType="Int32" Size="4" />
<asp:Parameter Name="单价" DbType="Decimal" Size="9" />
<asp:Parameter Name="厂商" DbType="String"  Size="40" />
<asp:Parameter Name="经办人" DbType="String"  Size="40" />
<asp:Parameter Name="保管员" DbType="String"  Size="40" />
<asp:Parameter Name="备注" DbType="String"  Size="100" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" />
<asp:Parameter Name="类别ID" DbType="Int32" Size="4"  />
<asp:Parameter Name="计划年度" DbType="Int16" Size="2" />
<asp:Parameter Name="计划月份" DbType="Byte" Size="1" />
<asp:Parameter Name="日期" DbType="Date"  Size="3" />
<asp:Parameter Name="数量" DbType="Int32" Size="4" />
<asp:Parameter Name="单价" DbType="Decimal" Size="9" />
<asp:Parameter Name="厂商" DbType="String"  Size="40" />
<asp:Parameter Name="经办人" DbType="String"  Size="40" />
<asp:Parameter Name="保管员" DbType="String"  Size="40" />
<asp:Parameter Name="备注" DbType="String"  Size="100" />
</UpdateParameters>
</asp:SqlDataSource>

<asp:Label ID="DHID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:HiddenField ID="BPID" runat="server" Value="" />
<asp:HiddenField ID="GuiGe" runat="server" Value="" />
<asp:HiddenField ID="DanWei" runat="server" Value="" />


<div id="wintop" class="wintop" style="display:none;">备品备件到货记录录入</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<asp:Button ID="Button_Save" runat="server" Text="保 存" UseSubmitBehavior="false" 
        CssClass="button" onclick="Button_Save_Click"  />

<asp:Button ID="Button_ReNew" runat="server" Text="录入新记录" UseSubmitBehavior="false"
        CssClass="button2" onclick="Button_ReNew_Click" />
        
<asp:Button ID="Button_Close" runat="server" Text="关 闭" UseSubmitBehavior="false"  Visible="true"
        CssClass="button" OnClientClick="parent.swin2_close();return false;" />

</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" HorizontalAlign="Center">

<table border=1 style="border-collapse:separate;font-size:14px;margin-top:7px;margin-bottom:24px;">
<tr>
<td colspan=4 align=center style="font-weight:bold; letter-spacing:10px;font-size:16px;border:none;">到货信息</td>
</tr>
<tr>
<td align=right>计划年度:</td>
<td><asp:DropDownList ID="NianDu" runat="server" Width="120">
    <asp:ListItem Value="2008">2008</asp:ListItem>
    <asp:ListItem Value="2009">2009</asp:ListItem>
    <asp:ListItem Value="2010">2010</asp:ListItem>
    <asp:ListItem Value="2011">2011</asp:ListItem>
    <asp:ListItem Value="2012">2012</asp:ListItem>
    <asp:ListItem Value="2013">2013</asp:ListItem>
    <asp:ListItem Value="2014">2014</asp:ListItem>
    <asp:ListItem Value="2015">2015</asp:ListItem>
    <asp:ListItem Value="2016">2016</asp:ListItem>
    <asp:ListItem Value="2017">2017</asp:ListItem>
    <asp:ListItem Value="2018">2018</asp:ListItem>
    <asp:ListItem Value="2019">2019</asp:ListItem>
    <asp:ListItem Value="2020">2020</asp:ListItem>
    </asp:DropDownList></td>
<td align=right>计划月份:</td>
<td><asp:DropDownList ID="YueFen" runat="server" Width="120">
    <asp:ListItem Value="1">1</asp:ListItem>
    <asp:ListItem Value="2">2</asp:ListItem>
    <asp:ListItem Value="3">3</asp:ListItem>
    <asp:ListItem Value="4">4</asp:ListItem>
    <asp:ListItem Value="5">5</asp:ListItem>
    <asp:ListItem Value="6">6</asp:ListItem>
    <asp:ListItem Value="7">7</asp:ListItem>
    <asp:ListItem Value="8">8</asp:ListItem>
    <asp:ListItem Value="9">9</asp:ListItem>
    <asp:ListItem Value="10">10</asp:ListItem>
    <asp:ListItem Value="11">11</asp:ListItem>
    <asp:ListItem Value="12">12</asp:ListItem>
    </asp:DropDownList></td>
</tr>

<tr>
<td width=100 align=right>品名:</td>
<td width=180><asp:TextBox ID="PinMing" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
<td width=100 align=right>规格:</td>
<td width=180><asp:Label ID="Label_GuiGe" runat="server" Text=""></asp:Label>&nbsp;</td>
</tr>

<tr>
<td align=right>数量:</td>
<td><asp:TextBox ID="ShuLiang" runat="server" CssClass="textbox" Width="120"></asp:TextBox><asp:Label ID="Label_DanWei" runat="server" Text=""></asp:Label></td>
<td align=right>单价(元):</td>
<td><asp:TextBox ID="DanJia" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
</tr>

<tr>
<td align=right>到货时间:</td>
<td><asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="absmiddle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" /></td>
<td align=right>厂商:</td>
<td><asp:TextBox ID="ChangShang" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
</tr>

<tr>
<td align=right>经办人:</td>
<td><asp:TextBox ID="JingBan" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
<td align=right>保管员:</td>
<td><asp:Label ID="BaoGuan" runat="server" Text=""></asp:Label>&nbsp;</td>
</tr>
<tr>
<td align=right>备注:</td>
<td colspan="3"><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="407"></asp:TextBox></td>
</tr>

</table>

</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="·" CssClass="prompt"></asp:Label>
</asp:Panel>

</form>

<script >
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }


    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left = (getObjectLeft(o) - 40) + "px";
        ds.style.top = (getObjectTop(o) - 60) + "px";
        ds.style.display = 'block';
        showcalendar();
    }
    var BPID = document.getElementById("BPID");
    var GuiGe = document.getElementById("GuiGe");
    var DanWei = document.getElementById("DanWei");
    
    //自动完成
    var AutoComplete_Container = document.getElementById("AutoComplete_Container");
    if (!AutoComplete_Container) {//创建容器
        AutoComplete_Container = document.createElement("DIV");
        AutoComplete_Container.id = "AutoComplete_Container";
        AutoComplete_Container.className = "AutoComplete_Container";
        AutoComplete_Container.style.display = "none";
        document.body.appendChild(AutoComplete_Container);
    }
    var AutoComplete_Lists = new Array();
    var AutoComplete_Target = null;
    var AutoComplete_LastValue = "";
    function AutoComplete_SetHotRow(o) {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        hotrow.id = "";
        hotrow.className = "AutoComplete_Row";
        o.id = "AutoComplete_HotRow";
        o.className = "AutoComplete_HotRow";
    }
    function AutoComplete_Select() {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        if (hotrow) {
            var li = AutoComplete_Lists[hotrow.rowIndex].split("\t");
            BPID.value = li[0];
            AutoComplete_Target.value = li[1];
            var next = AutoComplete_Target.parentNode.nextSibling.nextSibling;
            next.innerHTML = li[2] + "&nbsp;";
            GuiGe.value = li[2];
            DanWei.value = li[3];
            document.getElementById("Label_DanWei").innerHTML = li[3] + "&nbsp;";
            document.getElementById("DanJia").value = li[4];
        }
    }
    function AutoComplete_Response(http) {
        if (http.status != 200) {
            alert("服务器错误: " + http.status + " " + http.statusText);
            return;
        }
        if (http.responseText == "") {
            AutoComplete_Container.innerHTML = "<div style=padding:3px;font-size:14px;>没有查询到您录入的品种</div>";
        }
        else {
            var className = "AutoComplete_HotRow";
            var rs = http.responseText.split("\n");
            var tmp = "<table>";
            var cs;
            var id = " id=AutoComplete_HotRow";
            for (var i = 0; i < rs.length - 1; i++) {
                AutoComplete_Lists[i] = rs[i];
                cs = rs[i].split("\t");
                tmp += "<tr" + id + " class=" + className + " onmousemove=AutoComplete_SetHotRow(this); onmousedown=AutoComplete_Select();><td style='width:90pt;padding:1px 2px 0px 2px;'>"
                    + cs[1] + "</td><td align=center style=width:90pt>"
                    + cs[2] + "</td><td align=center style=width:80pt>"
                    + cs[4] + "/" + cs[3] + "</td></tr>";
                className = "AutoComplete_Row";
                id = "";
            }
            tmp += "</table>";
            AutoComplete_Container.innerHTML = tmp;
        }

        AutoComplete_Container.style.display = "";
        AutoComplete_Container.style.top = (getObjectTop(AutoComplete_Target) + AutoComplete_Target.clientHeight + 2) + "px";
        AutoComplete_Container.style.left = (getObjectLeft(AutoComplete_Target)) + "px";
    };
    function AutoComplete_HideContainer() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
    }
    function AutoComplete_SetValue(value) {
        if (typeof (AutoComplete_Target.value) != "undefined") AutoComplete_Target.value = value;
        else if (typeof (AutoComplete_Target.innerText) != "undefined") AutoComplete_Target.innerText = value;
        else if (typeof (AutoComplete_Target.textContent) != "undefined") AutoComplete_Target.textContent = value;
    }
    function AutoComplete() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
        else if (AutoComplete_Target != document.activeElement) {
            AutoComplete_Target = null;
            setTimeout("AutoComplete_HideContainer()", 100);
        }
        else {
            var txt;
            if (typeof (AutoComplete_Target.value) != "undefined") txt = AutoComplete_Target.value;
            else if (typeof (AutoComplete_Target.innerText) != "undefined") txt = AutoComplete_Target.innerText;
            else if (typeof (AutoComplete_Target.textContent) != "undefined") txt = AutoComplete_Target.textContent;

            txt = txt.replace(/^\s+/, '').replace(/\s+$/, '');
            if (txt == "") {
                AutoComplete_Container.style.display = "none";
            }
            else if (txt != AutoComplete_LastValue) {
                AutoComplete_LastValue = txt;
                var request = createRequest(AutoComplete_Response);
                request.open("GET", encodeURI("/jidong/备件查询.ashx?s=" + txt), true);
                request.send(null);
            }
        }
        setTimeout("AutoComplete()", 200);
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;

        if (tag == AutoComplete_Target && AutoComplete_Container.style.display != "none") {
            if (e.keyCode != 9) {
                BPID.value = "0";
                var next = AutoComplete_Target.parentNode.nextSibling.nextSibling;
                next.innerHTML = "&nbsp;";
                GuiGe.value = "";
                DanWei.value = "";
                document.getElementById("Label_DanWei").innerHTML = "&nbsp;";
                document.getElementById("DanJia").value = "";
            }
            if (e.keyCode == 38) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex > 0) {
                        lt.rows[hotrow.rowIndex - 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex - 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[lt.rows.length - 1].id = "AutoComplete_HotRow";
                        lt.rows[lt.rows.length - 1].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 40) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex < lt.rows.length - 1) {
                        lt.rows[hotrow.rowIndex + 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex + 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[0].id = "AutoComplete_HotRow";
                        lt.rows[0].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 13) {
                AutoComplete_Select();
                e.keyCode = 9;
            }
            else if (e.keyCode == 27) {
                AutoComplete_LastValue = "";
                tag.value = "";
            }
        }
        else if (e.keyCode == 13) {
            e.keyCode = 9;
        }

    }
    setTimeout("AutoComplete()", 200);
    //自动完成结束
    document.getElementById("PinMing").onfocus = function() {
        AutoComplete_LastValue = "";
        AutoComplete_Target = this;
        this.select();
    }
</script>
</body>
</html>
